package com.googlecode.transmutant.spring;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import com.googlecode.transmutant.Stepper 
import org.junit.Test;
import org.junit.runner.RunWith 
import org.springframework.beans.factory.annotation.Autowired 
import org.springframework.context.ApplicationContext 
import org.springframework.test.context.ContextConfiguration 
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner 

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("helloWorldRefAttributeOnly.xml")
public class TransmutantNamespaceHandlerRefAttributeTest {

	@Autowired
	ApplicationContext applicationContext
	
	@Test
	public void testCreateSteps() throws Exception {
		def bos = new ByteArrayOutputStream()
		System.setOut(new PrintStream(bos))
		StepsWrapper stepsWrapper = applicationContext.getBean("steps")
		def stepper = new Stepper()
		def steps = stepsWrapper.createSteps()
		stepper.step([steps.get(0).ref,steps.get(1).ref])
		assert bos.toString().equals("Hello World!")
	}
}
